C:\to_server\website\mrdcl-learning.com\mrdcl_files\INT-04\getstarted3.stp
start data,
serial number in columns 1-4,
card characters 1000,
order 1234567890xv,
ds $q1=$5/1,2,e,
x='Yes;
No;
Not stated<z>',
xt='Q1 Have you used MRDCL before?',
!
dm $q2=$6-8,e,
x='Ate at a restaurant;
Went to see a film;
Went to watch a sporting event;
None/NS',
xt='Q2 Activities in the past month',
!
f=ifbu,
!
di $iq3=$9-10,
xt='Q3 Number of children in family',
!
ds $q3=$iq3/0-3,>3,e,
x='No children;
1 child;
2 children;
3 children;
More than 3 children;
Not stated<z>',
xt='Q3 Number of children in family',
!
dm $myvar=$11/1.$12/1.$13/1,4+5,6..8,1.n2,n3..5,n6+n7,s,m,b,t,f,$$/1..2,
x='Column 11 Code 1 AND Column 12 Code 1 AND Column 13 Code 1;
Column 13 Code 4 OR 5;
Any of codes 6 thru 8 (same as 6+7+8);
Code 1 BUT NOT Code 2;
No codes 3 thru 5 (same as n3.n4.n5);
Not code 6 OR Not code 7 (Be careful with this one);
Single coded;
Multi coded;
Blank;
Always set ON;
Always set OFF;
Either of first 2 bits',
xt='My variable',
!It is highly unlikely you would define a variable like $myvar, but it is here to illustrate the different types
!of definitions you are allowed in MRDCL. Each bit is described in detail below
!
!$11/1.$12/1.$13/1 The character . (full stop/period) means AND in MRDCL. Therefore this means you want to see records
!  that have all three codes Column 11/1 and Column 12/1 and Column 13/1.
!4+5  There is no column here, so it continues to refer to column 13.
!               The character + (plus sign) means OR in MRDCL. Therefore this means either
!   code 4 or code 5 must be present. It is the same as 4..5 (see next bit)
!6..8  This means in the range of 6 to 8. It is, therefore, the same as 6+7+8 and means any code in the
!  range 6 thru 8
!1.n2  1.n2 means that code 1 must be present AND NOT code 2.
!n3..5  This means no codes in the range 3 thru 5. This is the same n3,n4.n5
!n6+n7  It is rare that you want this. It means records that are either not 6 or not 7. That is, it will be
!  all records EXCEPT those that have BOTH 6 AND 7.
!s  Means any record with a single code in that column
!m  Means any record with a multi code in that column
!b  Means any record that is blank in that column
!t  Means always set this bit to be TRUE
!f  Means always set this bit to be FALSE
!$$/1..2 $$ means refer to the bits in the current variable. You can only refer to previous bits. This is the
!  same as saying (1.2.3)+(4+5). Use of brackets are covered in the next variable.
!  single.
!
dm $myvar2=($9/1.$5/1)+($9/2),$6/1+$5/1.$9/2,($5/1.$9/1)+($5/2.$9/2),
x='($9/1 AND $5/1) OR $9/2;
($6/1 OR $5/1) AND $9/2;
($5/1 AND $9/1) OR ($5/2 AND $9/2)',
xt='Brackets',
!
dm $myvar3=$myvar/1,$myvar2/2,$myvar/1.$myvar2/1,
x='Bit 1 of myvar;
Bit 2 of myvar2;
Bit 1 of myvar AND bit 1 of myvar2',
xt='Picking up data from variables',
!
!You may use brackets in variable definitions. You are allowed nested levels of brackets for complex definitions.
!By default, MRDCL works from left to right. Sometimes this makes brackets redundant, although it is always advisable
!to use brackets when you are mixing AND with OR. The 3 bits of the above variable are discussed below
!
!$9/1.$5/1+$9/2    As MRDCL works from left to right the code will be translated as ($9/1.$5/1)+$9/2.
!$6/1+$5/1.$9/2    This will be interpreted as ($6/1 OR $5/1).$9/2
!(($5/1.$9/1)+($5/2.$9/2) The brackets would be parsed first and then the + condition would allow either part to make the bit true
!
dm $q2x=$7/1,$8/1,$6/1,e,
x='
Went to see a film;
Went to watch a sporting event;
Ate at a restaurant;
None/NS',
xt='Q2 Activities in the past month',
!
dm $varq2x=$q2x/1,$q2/2,$q2x/1.2,
x='Went to see a film (Remember it is bit 1 from $q2x);
Went to see a film (same from $q2);
Went to see film AND sporting event',
xt='Q2 combinations',
!
!The above illustrates an important when working with definitions from other variables. The syntax indicated above
!showing use of AND/OR works with variables as well as columns. However, if you are referring to a variable, you
!will be referring to its bit in the variable and not the code it came from. Often these may be the same, but consider
!$q2x. It picks up codes in the order 2,3,1 rather than 1,2,3. This means that code 2 is bit 1 of q2x. Code 3 is bit 2
!of q2x and code 1 is bit 3 of q2x.
!Therefore, the first two bits of $varq2x are the same. Make sure you understand this before you work with variables
!defined from other variables.
finish data,
start tables,
!
%jh='<jc>My project',
global bt#='All respondents',
f=sdv/spl180/uch/caz'0',
!
!f=sdv/spl180/uch introduces you to format settings. There are 3 types of format settings. These are numeric formats,
t#1=$myvar *,
!Here is a table for $myvar. It will give a total column only as there is no banner/break/header.
!
t#2=$myvar2 *,
!
t#3=$myvar3 *,
!
t#4=$varq2x *,
!
finish tables,
